package com.smartEdu.controller.app;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.smartEdu.commons.Session;
import com.smartEdu.commons.Tag_Tips;
import com.smartEdu.exception.ServiceException;
import com.smartEdu.response.Response;
import com.smartEdu.service.ArticleService;
@Controller
@RequestMapping(value="/app/article")
public class ArticleController extends AppBaseController {
	@Autowired
	@Qualifier(value="appresponse")
	public Response respContext;
	
	@Autowired
	@Qualifier(value="articleServiceImpl")
	private ArticleService articleService;
	
	@Override
	public String GetRespContent(Session sess) {
		return respContext.GetRespContent(sess);
	}
	
	@RequestMapping(value="/recommend")
	public void recommend(HttpServletRequest request,HttpServletResponse response){
		Session sess=null;
		try {
			sess=GetSession();
			sess.put(Tag_Tips.REQUEST, GetParameter(request));
			articleService.recommend(sess);
		} 
		catch (ServiceException e) {
			sess.put(Tag_Tips.RESPCODE, Tag_Tips.ERROR);
		}
		finally {
			SetResponse(response, sess);
		}
	}
	
	@RequestMapping(value="/detail")
	public void detail(HttpServletRequest request,HttpServletResponse response){
		Session sess=null;
		try {
			sess=GetSession();
			sess.put(Tag_Tips.REQUEST, GetParameter(request));
			articleService.showdetail(sess);
		} 
		catch (ServiceException e) {
			sess.put(Tag_Tips.RESPCODE, Tag_Tips.ERROR);
		}
		finally {
			SetResponse(response, sess);
		}
	}
	

	@RequestMapping(value="/getArticleByTitle")
	public void  getArticleByContent(HttpServletRequest request,HttpServletResponse response){
		Session sess=null;
		try {
			sess=GetSession();
			sess.put(Tag_Tips.REQUEST, GetParameter(request));
			articleService.getArticleByContent(sess);
		} 
		catch (ServiceException e) {
			sess.put(Tag_Tips.RESPCODE, Tag_Tips.ERROR);
		}
		finally {
			SetResponse(response, sess);
		}
	}


}
